import axios from "axios";

export default {
	// 开启命名空间
  namespaced: true,
  state: {
    list: [],
    loading: true,
  },
  getters: {},
  mutations: {
    setLoading(state, payload) {
      state.loading = payload;
    },
    setList(state, payload) {
      state.list = payload;
    },
  },
  actions: {
    async fetchList({ commit }) {
      commit("setLoading", true);
      const resp = await axios.get("/api/list");
      // await new Promise((resolve) => setTimeout(resolve, 5000));
      commit("setList", resp.data.data);
      commit("setLoading", false);
    },
  },
};
